<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        // 我们使用settimeout模拟一下回调地狱
        // setTimeout(() => {
        //     console.log(1);
        //     setTimeout(() => {
        //         console.log(2);
        //         setTimeout(() => {
        //             console.log(3);
        //         }, 3000);
        //     }, 2000);
        // }, 1000);

        function getData() {
            return new Promise((resolve, reject) => {
                setTimeout(() => {
                    console.log(1);
                    resolve(2);
                }, 1000);
            })
        }

        getData()
            .then(res => {
                return new Promise((resolve, reject) => {
                    setTimeout(() => {
                        console.log(2);
                        resolve(3);
                    }, res*1000);
                })
            })
            .then(res => {
                return new Promise((resolve, reject) => {
                    setTimeout(() => {
                        console.log(3);
                        resolve(4);
                    }, res*1000);
                })
            })
    </script>
</body>

</html>